﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace Xiaov.SmartWeb.Application.HXZB
{
    public partial class NhzbLeftDownData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                #region 获取参数
                string zbbm = "", dwbm = "", nf = "", yf = "", type = "";
                if (Request.QueryString["zbbm"] != null)
                {
                    zbbm = Request.QueryString["zbbm"].ToString();
                }
                if (Request.QueryString["dwbm"] != null)
                {
                    dwbm = Request.QueryString["dwbm"].ToString();
                }
                if (Request.QueryString["nf"] != null && Request.QueryString["yf"] != null)
                {
                    nf = Request.QueryString["nf"].ToString();
                    yf = Request.QueryString["yf"].ToString();
                }
                if (Request.QueryString["type"] != null)//数据信息 标题，数据
                {
                    type = Request.QueryString["type"].ToString();
                }
                #endregion
                string bbbm = "NH63";
                string zdmc = "XHHJ";
                switch (zbbm)
                {
                    case "NH6101"://电力
                        bbbm = "NH63";
                        zdmc = "XHHJ";
                        break;
                    case "NH6102"://原油
                        bbbm = "NH64";
                        zdmc = "YYHJ";
                        break;
                    case "NH6104"://天然气
                        bbbm = "NH65";
                        zdmc = "XHHJ";
                        break;
                    case "NH6105"://汽油
                        bbbm = "NH66";
                        zdmc = "QYHJ";
                        break;
                    case "NH6106"://柴油
                        bbbm = "NH66";
                        zdmc = "CYHJ";
                        break;
                    default:
                        break;
                }
                StringBuilder sbSql = new StringBuilder();
                sbSql.AppendFormat(@"select zbmc dwmc,{0} bnlj from {1} WHERE nf={2} and yf={3} and zbbm<>'{4}' and zbbm<>'{5}' and zbbm<>'{6}' and dwbm='{7}'",
                    zdmc, bbbm, nf, yf, bbbm + "HB", bbbm + "HBSC", bbbm + "HBFZ", dwbm);
                DataSet ds = Maticsoft.DBUtility.DbHelperOra.Query(sbSql.ToString());
                #region 输出数据
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (ds.Tables[0].Rows[i]["bnlj"].ToString() == "")
                        {
                            ds.Tables[0].Rows[i]["bnlj"] = 0;
                        }
                        if (type == "title")
                        {
                            if (i != ds.Tables[0].Rows.Count - 1)
                            {
                                Response.Write(ds.Tables[0].Rows[i]["dwmc"].ToString() + "\t");
                            }
                            else
                            {
                                Response.Write(ds.Tables[0].Rows[i]["dwmc"].ToString());
                            }
                        }
                        else if (type == "datas")
                        {
                            if (i != ds.Tables[0].Rows.Count - 1)
                            {
                                Response.Write(ds.Tables[0].Rows[i]["bnlj"].ToString() + "\t");
                            }
                            else
                            {
                                Response.Write(ds.Tables[0].Rows[i]["bnlj"].ToString());
                            }
                        }
                    }
                    Response.End();
                }
                #endregion                
            }
        }
    }
}